package Algorithm;

public class LC34 {
    public int[] searchRange(int[] nums, int target) {
        if(nums.length==0) return new int[]{-1,-1};
        int i=0;
        int j=nums.length-1;
        while(i<j){
            int mid=(i+j)/2;
            if(nums[mid]<target){
                i=mid+1;
            }else{
                j=mid;
            }
        }
        int L=j;
        if(nums[j]!=target) return new int[]{-1,-1};
        i=0;
        j=nums.length-1;
        while(i<j){
            int mid=(i+j+1)/2;
            if(nums[mid]<=target){
                i=mid;
            }else{
                j=mid-1;
            }
        }
        return new int[]{L,j};
    }
}
